package com.southminority.ethnic.controller.document.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 文件类型信息视图对象
 * 
 * @author SouthMinority
 */
@Data
@Schema(description = "文件类型信息视图对象")
public class FileTypeInfoVO {

    @Schema(description = "是否有PDF文件", example = "true")
    private Boolean hasPdf;

    @Schema(description = "PDF文件URL", example = "http://example.com/document.pdf")
    private String pdfUrl;

    @Schema(description = "PDF文件大小（字节）", example = "1048576")
    private Long pdfSize;

    @Schema(description = "是否有图片", example = "true")
    private Boolean hasImages;

    @Schema(description = "图片URLs列表")
    private List<String> imageUrls;

    @Schema(description = "图片数量", example = "5")
    private Integer imageCount;

    @Schema(description = "是否有音频", example = "false")
    private Boolean hasAudio;

    @Schema(description = "音频文件URL")
    private String audioUrl;

    @Schema(description = "音频文件大小（字节）")
    private Long audioSize;

    @Schema(description = "音频时长（秒）")
    private Integer audioDuration;

    @Schema(description = "是否有视频", example = "false")
    private Boolean hasVideo;

    @Schema(description = "视频文件URL")
    private String videoUrl;

    @Schema(description = "视频文件大小（字节）")
    private Long videoSize;

    @Schema(description = "视频时长（秒）")
    private Integer videoDuration;

    @Schema(description = "是否有其他主要文件（如PPT、DOC等）", example = "false")
    private Boolean hasOtherFile;

    @Schema(description = "其他主要文件URL")
    private String otherFileUrl;

    @Schema(description = "其他主要文件类型", example = "pptx")
    private String otherFileType;

    @Schema(description = "其他主要文件名称", example = "文献介绍.pptx")
    private String otherFileName;

    @Schema(description = "其他主要文件大小（字节）")
    private Long otherFileSize;

    @Schema(description = "是否有附件", example = "true")
    private Boolean hasAttachments;

    @Schema(description = "附件数量", example = "2")
    private Integer attachmentCount;

    @Schema(description = "所有可供下载的文件类型列表", example = "[\"pdf\", \"image\", \"attachment\"]")
    private List<String> availableTypes;

    /**
     * 根据当前对象的文件存在情况，更新并生成一个包含所有可用文件类型的列表。
     */
    public void updateAvailableTypes() {
        this.availableTypes = new java.util.ArrayList<>();
        if (Boolean.TRUE.equals(this.hasPdf)) {
            this.availableTypes.add("pdf");
        }
        if (Boolean.TRUE.equals(this.hasOtherFile) && this.otherFileType != null) {
            this.availableTypes.add(this.otherFileType != null ? this.otherFileType.toLowerCase() : "other");
        }
        if (Boolean.TRUE.equals(this.hasImages)) {
            this.availableTypes.add("image");
        }
        if (Boolean.TRUE.equals(this.hasAudio)) {
            this.availableTypes.add("audio");
        }
        if (Boolean.TRUE.equals(this.hasVideo)) {
            this.availableTypes.add("video");
        }
        if (Boolean.TRUE.equals(this.hasAttachments)) {
            this.availableTypes.add("attachment");
        }
    }
} 